package com.consumer;

import cn.hutool.core.lang.tree.parser.NodeParser;
import com.rabbitmq.client.*;
import org.apache.poi.hssf.record.DVALRecord;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class Consumer {
    public final static String QUEUE_NAME="hello";
    public static void main(String[] args) throws IOException, TimeoutException {
        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost("127.0.0.1");
        connectionFactory.setUsername("jdq");
        connectionFactory.setPassword("jdq123456");
        Connection connection = connectionFactory.newConnection();
        Channel channel = connection.createChannel();
        System.out.println("等待接收消息。。。。。。。");
        //推送的消息如何进行消费的接口回调
        DeliverCallback deliverCallback = (consumerTag, delivery) -> {
            String message = new String(delivery.getBody());
            System.out.println(message);
        };
        //取消消费的一个回调接口，如在消费的时候队列被删除掉了
        CancelCallback cancelCallback=(consumerTag)->{
            System.out.println("消费消息被中断");
        };
        /**
         * 消费者消费消费
         * 1.消费那个队列
         * 2.消费成功之后是否要自动应答true代表自动应答false手动应答
         * 3.消费者未成功消费的回调
         */
    }
}
